package com.quasar.hpatient.presenter;

import com.quasar.hpatient.model.httpmodel.AnotherResult;
import com.quasar.hpatient.model.httpmodel.DataStateResult;
import com.quasar.hpatient.model.medicalmodel.CaseinformationData;
import com.quasar.hpatient.model.requestmodel.RequestModel;
import com.quasar.hpatient.onInterface.AnotherResultListener;
import com.quasar.hpatient.onInterface.OnCaseHistoryListener;
/**
 * author : 许建宏
 * Date: 2017/12/13 0013
 * View:病例
 */

public class CaseHistoryPresenter {

    private RequestModel requestModel;
    private OnCaseHistoryListener onCaseHistoryListener;

    public CaseHistoryPresenter(OnCaseHistoryListener onCaseHistoryListener) {
        this.requestModel = new RequestModel();
        this.onCaseHistoryListener = onCaseHistoryListener;
    }

    //添加病例
    public void AddPatientCaseHistoryData(String hosId,String title,String description,String createTime,String cover){

        requestModel.AddPatientCaseHistoryData(hosId, title, description, createTime, cover, new AnotherResultListener<DataStateResult>() {
            @Override
            public void onSuccess(DataStateResult data) {
                onCaseHistoryListener.onSubmitSuccess(data);
            }

            @Override
            public void onError(String msg) {
                onCaseHistoryListener.onError(msg);
            }

            @Override
            public void onRefreshUI() {
                onCaseHistoryListener.onRefreshUI();
            }
        });
    }

    //获取病例
    public void GetPatientCaseHistory(String startTime,String endTime){
        requestModel.GetPatientCaseHistoryData(startTime, endTime, new AnotherResultListener<AnotherResult<CaseinformationData>>() {
            @Override
            public void onSuccess(AnotherResult<CaseinformationData> data) {
                onCaseHistoryListener.onListSuccess(data);
            }

            @Override
            public void onError(String msg) {
                onCaseHistoryListener.onError(msg);
            }

            @Override
            public void onRefreshUI() {
                onCaseHistoryListener.onRefreshUI();
            }
        });
    }

    //删除病例
    public void DeletePatientCase(String id){
        requestModel.DeletePatientCaseServer(id, new AnotherResultListener<DataStateResult>() {
            @Override
            public void onSuccess(DataStateResult data) {
                onCaseHistoryListener.onDeleteCase(data);
            }

            @Override
            public void onError(String msg) {
                onCaseHistoryListener.onError(msg);
            }

            @Override
            public void onRefreshUI() {
                onCaseHistoryListener.onRefreshUI();
            }
        });
    }

    //修改病例信息
    public void UpdatePatientCase(String id,String title,String description,String cover,String createTime,String hosId){

        requestModel.UpdatePatientCase(id, title, description, cover, createTime,hosId, new AnotherResultListener<DataStateResult>() {
            @Override
            public void onSuccess(DataStateResult data) {

                onCaseHistoryListener.onUpdateCase(data);
            }

            @Override
            public void onError(String msg) {
                onCaseHistoryListener.onError(msg);
            }

            @Override
            public void onRefreshUI() {
                onCaseHistoryListener.onRefreshUI();
            }
        });
    }

}
